﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Globalization;
using FinApp.ViewModels.Repositories;
using FinApp.ViewModels;

namespace FinApp.Views {
    public partial class CreditCardSelectorPage : PhoneApplicationPage {
        public CreditCardSelectorPage() {
            InitializeComponent();
            this.DataContext = ViewModelFactory.Instance.GetViewModel<CreditCardSelectorViewModel>();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) {
            base.OnNavigatedTo(e);
            IDictionary<string, string> parameters = this.NavigationContext.QueryString;
            string commerceId = parameters["CommerceId"];
            double quantity = double.Parse(parameters["Quantity"], CultureInfo.InvariantCulture);
            string password = parameters["Password"];
            string salt = parameters["Salt"];
            string checkField = parameters["CheckField"];

            CreditCardSelectorViewModel viewModel = ViewModelFactory.Instance.GetViewModel<CreditCardSelectorViewModel>();
            viewModel.CheckField = checkField;
            viewModel.Salt = salt;
            viewModel.Password = password;
            viewModel.Quantity = quantity;
            viewModel.CommerceId = commerceId;
            viewModel.LoadData();
        }
    }
}